$import("com.hh.workflow.task.AlreadyTaskList");
Ext.define('com.hh.workflow.task.HiTaskList', {
	extend : 'com.hh.workflow.task.AlreadyTaskList',
	gridAction : 'queryHiTaskListByPiid',
	title : '历史',
	constructor : function(config) {
		this.config = config || {};
		this.callParent(arguments);
		var page = this;
		var tpl = Ext
				.create(
						'Ext.XTemplate',
						'<img src="workflow-Task-showPic?pdid='
								+ this.extraParams.pdid
								+ '" />',
						'<tpl for=".">',
						'<div style=\'position:absolute; border:0px solid ;left:{left}px;top:{top}px;width:{width}px;height:{height}px;\'><img onClick="javascript:com.hh.workflow.task.HiTaskList.selectGrid(\''
								+ page.id
								+ '\',\'{actid}\')" style=\'cursor: pointer;\' src=\'{src}\' /></div>',
						'</tpl>');
		Request.request('workflow-Task-queryPicHiTask', {
			pdid : this.extraParams.pdid,
			piid : this.extraParams.piid
		}, function(result) {
			var html = tpl.apply(result);
			page.panel.add(Ext.create("Ext.panel.Panel", {
				region : 'north',
				collapsible : true,
				autoScroll : true,
				split : true,
				height : page.height / 2,
				title : '流程图',
				html : html
			}));
		});
	},
	statics : {
		selectGrid : function(pageid, actid) {
			var page = Ext.getCmp(pageid);
			var dataList = [];
			page.grid
					.getStore()
					.each(
							function(record) {
								if (actid == record
										.get("activityId")) {
									var data = {};
									Ext
											.apply(data,
													record.data);
									data.createTime = Ext.util.Format
											.date(
													data.createTime,
													'Y年m月d日 H时i分s秒');
									data.endTime = Ext.util.Format
											.date(data.endTime,
													'Y年m月d日 H时i分s秒');
									Request
											.synRequestObject(
													'workflow-Task-queryCommentByTaskId',
													{
														taskId : data.id
													},
													function(
															result) {
														data.message = result[0];
													});
									dataList.push(data);
								}
							});
			var data = {};
			if (dataList.length > 0) {
				data = dataList[0]
			}
			var tpl = Ext
					.create(
							'Ext.XTemplate',
							'<tpl for=".">',
							'<span class=labelText>办理人：</span>{assigneeName}<br/>',
							'<span class=labelText>创建时间：</span>{createTime}<br/>',
							'<span class=labelText>结束时间：</span>{endTime}<br/>',
							'<span class=labelText>意见：</span>{message}<br/>',
							'<span class=labelText>耗时：</span>{durationInMillis}',
							'<hr/></tpl>');

			var grid = page.getFileGrid();

			var form = Ext.create('com.hh.base.BaseFormPanel',
					{
						buttons : null,
						items : [ {
							xtype : 'fieldset',
							title : '节点历史',
							html : tpl.apply(dataList),
							columnWidth : 1
						}, grid ]
					});
			var window = Ext.create('Ext.window.Window', {
				width : page.width - 100,
				height : page.height - 100,
				maximizable : true,
				minimizable : true,
				layout : {
					type : 'border',
					padding : '2 2 2 2'
				},
				autoScroll : true,
				modal : true,
				title : '节点历史',
				items : [ form ]
			}).show();
		}
	}
});